import type { RsbuildPlugin } from "@rsbuild/core";
import { type GenerateApiOption, generateApi } from "swagger-typescript-api";

export default function pluginSwagger(
	options: GenerateApiOption,
): RsbuildPlugin {
	return {
		name: "plugin-swagger",
		setup(api) {
			api.onBeforeStartDevServer(async () => {
				await generateApi(options);
			});
		},
	};
}
